package com.smart.controller;

import com.smart.common.ResultVo;
import com.smart.entity.ArticleDetails;
import com.smart.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api")
public class UserArticleController {

    @Autowired
    ArticleService articleService;

    @GetMapping("/article/details")
    public ResultVo ArticleDetails(Integer id) {
        System.out.println(id+"aaabbb");
        Map<String, Object> articleDetails = articleService.ArticleDetails(id);

        return ResultVo.ok().data("item", articleDetails);
    }

    @GetMapping("/article/list")
    public ResultVo ArticleIndexList(Integer currentPage,Integer pageSize) {
        Map<String, Object> articles = articleService.ArticleIndexList(1, 10);
        return ResultVo.ok().data("item", articles);
    }

    @GetMapping("/article/list/class")
    public ResultVo ArticleListClass(Integer currentPage, Integer pageSize,Integer classId) {
        Map<String, Object> articles = articleService.ArticleListClass(1,10,classId);
        return ResultVo.ok().data("item", articles);
    }
}
